<template>
  <div>
    <el-form :inline="true"  class="demo-form-inline">
         <el-form-item label="请选择时间">
    <el-date-picker
      v-model="value1"
      value-format="yyyy-MM-dd"
      type="date"
      placeholder="选择日期时间">
    </el-date-picker>
    </el-form-item>
    <el-form-item label="员工名字">
    <el-input v-model="name" placeholder="输入员工名字"></el-input>
  </el-form-item>
    <el-button type="primary" @click="onSubmit">查询</el-button>
    </el-form>




    <el-table
    :data="list"
    border
    style="width: 800px">
    <el-table-column
      fixed
      prop="deviceid"
      label="设备id"
      width="150">
    </el-table-column>
    <el-table-column
      prop="username" 
      label="员工名字"
      width="120">
    </el-table-column>
    <el-table-column
      prop="temperature"
      label="温度"
      width="120">
    </el-table-column>
    <el-table-column
      prop="humidity"
      label="湿度"
      width="120">
    </el-table-column>
  <el-table-column
      prop="light"
      label="光照"
      width="120">
    </el-table-column>
  
        <el-table-column
      prop="createtime"
      label="创建时间"
      width="120">
    </el-table-column>
  
  
    
  </el-table>





  <el-pagination
@current-change="topages"
@next-click="next"
@prev-click="pre"
  background
  layout="prev, pager, next"
  :page-size="size"
  :total="total">
</el-pagination>

  </div>



</template>

<script>
export default {
    data() {
        return {
            value1:"",
            name:"",
            current:1,
            size:5,
            list:[],
            total:1,
        }
    },
    mounted() {
     this.getshuju()
    },
    methods: {
        // 获取数据
        async getshuju(){
            let result= await this.$API.user.getShuju(this.value1,this.name,this.current,this.size)
            console.log(result.code);
            if(result.code==200){
                this.list=result.data.records
                this.total=result.data.total
            }
        },
        onSubmit(){
            this.getshuju()
        },
           // 切换页面
    topages(e) {
      this.current = e;
      this.getshuju();
    },
    //切换下一页
    next() {
      this.current++;
      this.getshuju();
    },
    // 切换上一页
    pre() {
      this.current--;
      this.getshuju();
    },
        
    },
}
</script>

<style>

</style>